library example_package1;

import 'package:example_package1/arg/package1_1arg.dart';
import 'package:riki_router/riki_router.dart';

class ExamplePackage1 {
  // 工厂模式
  factory ExamplePackage1() => _getInstance();

  static ExamplePackage1 get instance => _getInstance();
  static ExamplePackage1? _instance;

  ExamplePackage1._internal();

  static ExamplePackage1 _getInstance() {
    if (_instance == null) {
      _instance = ExamplePackage1._internal();
    }
    return _instance!;
  }

  static const String PACKAGE = 'example_package';

  bool _isInit = false;

  void init() {
    if (_isInit) return;
    _isInit = true;

    RikiRouter.instance.expandConvert(<T extends Object?>(dynamic value) {
      if (Package1_1Arg.fromJson({}) is T && value is Map<dynamic, dynamic>) {
        return Package1_1Arg.fromJson(value) as T;
      }
      return null;
    });
  }
}
